from django.db import models

# Create your models here.

class UserModel(models.Model):
    username = models.CharField(max_length=20, verbose_name='用户名')
    password = models.CharField(max_length=256, verbose_name='密码')
    mobile = models.CharField(max_length=11, verbose_name='手机号', blank=True, null=True)
    email = models.CharField(max_length=40, verbose_name='邮箱', blank=True, null=True)
    class Meta:
        db_table = 'tb_user'
        verbose_name = '用户信息表'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.username

class InformationModel(models.Model):
    img = models.CharField(max_length=400, verbose_name='图片信息')
    briefly = models.TextField(verbose_name='简介')
    count = models.IntegerField(verbose_name='播放量')
    time = models.CharField(max_length=100, verbose_name='上传时间')
    user = models.ForeignKey(UserModel, models.CASCADE, verbose_name='所属用户')
    class Meta:
        db_table = 'tb_information'
        verbose_name = '主页信息表'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.user.username